﻿using System;

namespace DbMetadata
{
    /// <summary>
    /// Provides basic metadata information for primary and foreign key constraints.
    /// </summary>
    [Serializable]
    public abstract class DbKeyInfo
    {
        /// <summary>
        /// Gets or sets the name of the key constraint that this <see cref="DbKeyInfo"/> represents.
        /// </summary>
        /// <value></value>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the <see cref="DbTableInfo"/> that is the owner of the <see cref="DbKeyInfo"/>.
        /// </summary>
        /// <value></value>
        public DbTableInfo Table { get; set; }

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            if (!string.IsNullOrEmpty(Name))
                return Name;

            return base.ToString();
        }
    }
}
